/*
 * @Description: 
 * @Author: 赵大壮
 * @Date: 2021-12-06 17:18:37
 * @LastEditTime: 2024-07-23 16:25:01
 * @LastEditors: 赵大壮
 */
import { Component, Vue, Inject } from "vue-property-decorator";
import DZServiceInves from "../../service/DZServiceInves";
import UiDialogAddBase from "@/components/ui-dialog/UiDialogAddBase.vue"
import UiDialogAddTemplate from "@/components/ui-dialog/UiDialogAddTemplate.vue"
import DZModelQuesiton from "../../model/DZModelQuesiton";
import dzMsgBox from "@/utils/DZMessageBox";
import UiDialogEditBase from "@/components/ui-dialog/UiDialogEditBase.vue";

@Component({
    components: { UiDialogAddBase, UiDialogEditBase, UiDialogAddTemplate }
})
export default class Index extends Vue {

    s_inves = new DZServiceInves();

    dialog_add_base = false;

    dialog_add_template = false;

    created() {
        this.s_inves.net_list_question();
        this.s_inves.net_list_inv_all();
    }

    mounted() {

    }

    beforeDestroy() {

    }

    action_list_base(){
        this.s_inves.net_list_question();
    }

    action_add_base(data: DZModelQuesiton) {
        this.s_inves.m_inv_question = data;
        this.s_inves.net_add_question(() => {
            this.s_inves.net_list_question();
        });
    }

    action_can_edit(data){
        this.s_inves.net_base_inuse(data)
    }

    action_edit_base(data) {
        this.s_inves.m_inv_question_edit = Object.assign({},data)
        this.s_inves.dialog_edit_base = true
    }

    action_update_base(data){
        this.s_inves.net_edit_question(data,() => {
            this.s_inves.net_list_question();
        });
    }

    action_del_base(baseId) {
        this.s_inves.m_inv_question.id = baseId;
        dzMsgBox.del("是否删除该信息？", () => {
            this.s_inves.net_del_question(() => {
                this.s_inves.net_list_question();
            });
        })
    }

    action_add_template(name: string) {
        this.s_inves.m_template_question.name = name;
        var idList = [];
        for (const item of this.s_inves.m_template_question.list_question) {
            idList.push(item.id);
        }
        this.s_inves.m_template_question.questionList = idList.join(",")
        this.s_inves.net_add_template_question(() => {
            this.$router.back();
        })
    }
    // action_page_change(current) {
    //     this.s_inves.m_page.page = current;
    //     this.s_inves.net_list_question();
    // }

    action_table_selected(val) {
        this.s_inves.m_template_question.list_question = val
    }

    action_select_change(){
        this.s_inves.net_list_question();
    }
}